package com.fks.fks_service.config;//package com.fks.fks_service.config;
//
//import com.google.gson.Gson;
//import com.zrjk.zrjk_service.base.JsonResult;
//import com.zrjk.zrjk_service.base.ResultCode;
//import com.zrjk.zrjk_service.mapper.*;
//import com.zrjk.zrjk_service.pojo.*;
//import com.zrjk.zrjk_service.pojo.user.UserDB;
//import com.zrjk.zrjk_service.service.SysAppService;
//import com.zrjk.zrjk_service.utils.*;
//import com.zrjk.zrjk_service.utils.huaiannydsj.DateUtil;
//import com.zrjk.zrjk_service.utils.huaiannydsj.HttpUtil;
//import com.zrjk.zrjk_service.utils.weifengqi.InvoiceInfo;
//import com.zrjk.zrjk_service.utils.weifengqi.UserId;
//import okhttp3.*;
//import org.apache.commons.codec.binary.Base64;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.util.StringUtils;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//import org.springframework.web.client.RestTemplate;
//import org.springframework.web.servlet.ModelAndView;
//
//import javax.servlet.http.HttpServletRequest;
//import java.io.BufferedReader;
//import java.io.IOException;
//import java.io.UnsupportedEncodingException;
//import java.net.URLEncoder;
//import java.util.HashMap;
//import java.util.Map;
//
//@RestController
//public class EnterpriseServiceController {
//    private static final Logger log = LoggerFactory.getLogger(EnterpriseServiceController.class);
//
//    @Autowired
//    AppDBMapper appDBMapper;
//    @Autowired
//    SysAppService appService;
//    @Autowired
//    VerifyDBMapper verifyDBMapper;
//    @Autowired
//    UserDBMapper userDBMapper;
//    @Autowired
//    MapCreditMapper mapCreditMapper;
//    @Autowired
//    RestTemplate restTemplate;
//    @Autowired
//    WeiFengWangAuthMapper weiFengWangAuthMapper;
//    //系统路径
//    @Value("${zrjk.serviceUrl}")
//    private String serviceUrl;
//
//    private static String weifengwang_interfaceCode = "3d9a9a48e2994636a8df32bbe3109bfdHAZDS";
//    private static String weifengwang_secretKey = "0U0kw5EFUJSRdxXeQPOU6WTLql1yjjeflLL2xdOJ495DDYYzDEsYU1ahBH947DnG";
////    private static String weifengwang_notify = "https://qiyitong91.com/api/enterpriseServiceNotify";
//    private static String weifengwang_notify = "http://afgaiq.natappfree.cc/api/enterpriseServiceNotify";
//
//    @RequestMapping("/api/enterpriseServiceIndexEndCallback")
//    public Map<String, Object> enterpriseServiceIndexEndCallback(HttpServletRequest request) {
//        //请求参数
//        //打印请求体
//        String contentType = request.getContentType();
//        log.info("enterpriseServiceIndexEndCallback 请求参数params:");
//        if (contentType!=null){
//            log.error("请求体格式：{}",contentType.toString());
//            BufferedReader reader = null;
//            try {
//                reader = request.getReader();
//                StringBuilder requestBody = new StringBuilder();
//                String line;
//                while ((line = reader.readLine()) != null) {
//                    requestBody.append(line);
//                }
//                log.info("请求体内容：{}",requestBody.toString());
//            } catch (IOException e) {
//                e.printStackTrace();
//            }
//        }else {
//            log.info("请求体为空！ ");
//        }
//        Map<String, Object> resultMap = new HashMap<>();
//        resultMap.put("reasonSuccess", "true");
//        resultMap.put("reasonCode", "200");
//        resultMap.put("reasonDesc", "通知成功");
//        return resultMap;
//    }
//
//
//    @RequestMapping("/api/enterpriseServiceRejectionCallback")
//    public Map<String, Object> enterpriseServiceRejectionCallback(HttpServletRequest request) {
//        //请求参数
//        //打印请求体
//        String contentType = request.getContentType();
//        log.info("enterpriseServiceRejectionCallback 请求参数params:");
//        if (contentType!=null){
//            log.error("请求体格式：{}",contentType.toString());
//            BufferedReader reader = null;
//            try {
//                reader = request.getReader();
//                StringBuilder requestBody = new StringBuilder();
//                String line;
//                while ((line = reader.readLine()) != null) {
//                    requestBody.append(line);
//                }
//                log.info("请求体内容：{}",requestBody.toString());
//            } catch (IOException e) {
//                e.printStackTrace();
//            }
//        }else {
//            log.info("请求体为空！ ");
//        }
//        Map<String, Object> resultMap = new HashMap<>();
//        resultMap.put("reasonSuccess", "true");
//        resultMap.put("reasonCode", "200");
//        resultMap.put("reasonDesc", "通知成功");
//        return resultMap;
//    }
//
//    @RequestMapping("/api/enterpriseServiceAuthorizeEndCallback")
//    public Map<String, Object> enterpriseServiceAuthorizeEndCallback(HttpServletRequest request) {
//        //请求参数
//        //打印请求参数信息
//        Map<String, String[]> parameterMap = request.getParameterMap();
//        if (parameterMap != null){
//            log.info("enterpriseServiceAuthorizeEndCallback 请求参数params:");
//            parameterMap.forEach((k,v)->{
//                for (String s : v) {
//                    log.info(k+":"+s);
//                }
//            });
//        }else {
//            log.info("请求参数params为空！");
//        }
//        Map<String, Object> resultMap = new HashMap<>();
//        resultMap.put("reasonSuccess", "true");
//        resultMap.put("reasonCode", "200");
//        resultMap.put("reasonDesc", "通知成功");
//        return resultMap;
//    }
//
//
//    @RequestMapping("/api/enterpriseServiceNotify")
//    public ModelAndView enterpriseServiceNotify(HttpServletRequest request) {
//        ModelAndView modelAndView = new ModelAndView();
//        modelAndView.setViewName("weifengwangok");
//        modelAndView.addObject("icon", "/img/pay_ok.png");
//        modelAndView.addObject("msg", "授权成功");
//        //请求参数
//        String message = request.getParameter("message");
//        if (StringUtils.isEmpty(message)) {
//            modelAndView.addObject("icon", "/img/tip_p.png");
//            modelAndView.addObject("msg", "数据为空");
//            return modelAndView;
//        }
//        log.info("enterpriseServiceNotify message：" + message);
//        // 解密
//        String decryptResult = "";
//        try {
//            decryptResult = AESUtils.decrypt(new String (Base64.decodeBase64(message.getBytes()), AESUtils.ENCODING ), AESUtils.KEY);
//        } catch (UnsupportedEncodingException e) {
//            log.error("enterpriseServiceNotify UnsupportedEncodingException error", e);
////            return JsonResult.error(ResultCode.not_exists, "解码错误");
//            modelAndView.addObject("icon", "/img/tip_p.png");
//            modelAndView.addObject("msg", "解码错误");
//        }
////        log.info("解密后：" + new String(decryptResult));
////        String decryptResult = AESUtils.decrypt(message, AESUtils.KEY);
//        log.info("enterpriseServiceNotify 解密后：" + decryptResult);
//        CnWeiFengWangAuth cnWeiFengWangAuth = new Gson().fromJson(decryptResult, CnWeiFengWangAuth.class);
//        if (!"00".equals(cnWeiFengWangAuth.getRetCode())) {
////            return JsonResult.error(ResultCode.token_error,"税务授权失败");
//            modelAndView.addObject("icon", "/img/tip_p.png");
//            modelAndView.addObject("msg", "税务授权失败");
//        }
//        CnWeiFengWangAuth db_w = weiFengWangAuthMapper.getByOrderNo(cnWeiFengWangAuth.getOrderNo());
//        if (db_w == null) {
////            return JsonResult.error(ResultCode.token_error,"不存在税务授权记录");
//            modelAndView.addObject("icon", "/img/tip_p.png");
//            modelAndView.addObject("msg", "不存在税务授权记录");
//        }
//        db_w.setRetCode(cnWeiFengWangAuth.getRetCode());
//        db_w.setTaxNo(cnWeiFengWangAuth.getTaxNo());
//        db_w.setNSRSBH(cnWeiFengWangAuth.getNSRSBH());
//        db_w.setHasAuth(1);
//        db_w.setAuthTime(DateUtils.getNowTime());
//        int success = weiFengWangAuthMapper.updateAuth(db_w);
//        if (success == 0) {
////            return JsonResult.error(ResultCode.token_error,"税务授权更新失败");
//            modelAndView.addObject("icon", "/img/tip_p.png");
//            modelAndView.addObject("msg", "税务授权更新失败");
//        }
//        return modelAndView;
//    }
//
//    @RequestMapping("/api/enterpriseServiceAuthorization")
//    public Map<String, Object> enterpriseServiceAuthorization(HttpServletRequest request) {
//        String appCode = request.getHeader("zrjkAppcode");
//        //检测app所属
//        CnApp cnApp = appDBMapper.selectAppByAppCode(appCode);
//        if (cnApp == null)
//            return JsonResult.error(ResultCode.app_not_exists,"app不存在");
//        //请求参数
//        String token = request.getParameter("token");
//        String companyName = request.getParameter("companyName");
//        String taxpayerId = request.getParameter("taxpayerId");
////        String orderNo = request.getParameter("orderNo");
//        if (StringUtils.isEmpty(token)
//                || StringUtils.isEmpty(companyName)) {
//            return JsonResult.error(ResultCode.not_exists,"缺少参数");
//        }
//        //用户校验
//        VerifyDB verifyDB = verifyDBMapper.getVerifyDBByToken(token);
//        if (verifyDB == null) {
//            return JsonResult.error(ResultCode.token_error,"请重新登录");
//        }
//        UserDB reqUserDB = userDBMapper.getUserById(verifyDB.getUid());
//        if (reqUserDB == null) {
//            return JsonResult.error(ResultCode.not_exists,"用户不存在");
//        }
////        if (serviceUrl.contains("192.168.0")) {
////            return JsonResult.success("成功").data("https://www.enterpriseservice.cn/auth/#/authorization?webAuthorizeChannelCode=qkplf&cburl=http%3A%2F%2Ft4dexp.natappfree.cc%2Fapi%2FenterpriseServiceNotify&message=UGJFc0kweDFmUCtrZEFEV0pjemsxaFo3VEE4OEZCbjhQbFJpbUV4aWMwMzZTTkkrTTNScDROazZkRVIyTlVKNm9abEpMS0xIMy9ySUpUcXlxNmtpc3YrTWl5dHFERXRyVElXQ1NueE5qWHc5bkpKRnVmRzVFR2FsSitiTmFLZnQ%3D&url_id=551fc7d0bc1411ee984002420a140021").put("orderNo", "zrjkZlkycMjSCG2u1706250600963");
////        }
//        //user_id
//        int remainTimes = 3000;
//        int expireTimeHour = 12;
//        String expireTime = "180";
//        Map<String, Object> userIdMap = new HashMap<>();
//        userIdMap.put("interfaceCode",weifengwang_interfaceCode);
//        userIdMap.put("secretKey",weifengwang_secretKey);
//        userIdMap.put("remain_times",remainTimes);
////        userIdMap.put("expire_time_hour",12);
//        userIdMap.put("expire_time",expireTime);
//        String userIdJson = new Gson().toJson(userIdMap);
////        String userIdJson = "{\"remain_times\":1,\"secretKey\":\"0U0kw5EFUJSRdxXeQPOU6WTLql1yjjeflLL2xdOJ495DDYYzDEsYU1ahBH947DnG\",\"expire_time_hour\":1,\"interfaceCode\":\"3d9a9a48e2994636a8df32bbe3109bfdHAZDS\"}";
//        log.info("user_id请求参数："+userIdJson);
//        String userIdUrl = "https://api.wfq2020.com/mini-program-index-api/accounts/authorize_url_ids";
//        Map tmepUserIdMap = restTemplate.postForObject(userIdUrl, userIdMap, Map.class);
//        String userIdResultStr = new Gson().toJson(tmepUserIdMap);
//        log.info("userIdResultStr："+userIdResultStr);
//        UserId userIdResultMap = new Gson().fromJson(userIdResultStr, UserId.class);
//        log.info("userIdResultMap："+new Gson().toJson(userIdResultMap));
//        String url_id = "";
//        if (userIdResultMap.getCode() == 200) {
//            url_id = userIdResultMap.getData().getUrlId();
//        } else {
//            return JsonResult.error(ResultCode.not_exists,userIdResultMap.getMessage());
//        }
//        //message
//        Map<String, String> map = new HashMap<>();
//        String tempOrderNo = "zrjk"+TokenUtils.makeToken(12)+System.currentTimeMillis();
//        map.put("orderNo", tempOrderNo);
//        map.put("companyName", companyName);
//        String content = new Gson().toJson(map);
//        // 加密
//        String encryptResult = AESUtils.encrypt(content, AESUtils.KEY);
//        log.info("加密后：" + encryptResult);
//
//        String encryptResultBase64 = null;
//        try {
//            encryptResultBase64 = new String (Base64.encodeBase64(encryptResult.getBytes()), AESUtils.ENCODING);
//            log.info("base64后：" + encryptResultBase64);
//        } catch (UnsupportedEncodingException e) {
//            log.error("enterpriseServiceAuthorization UnsupportedEncodingException error", e);
//            return JsonResult.error(ResultCode.not_exists, "编码错误");
//        }
//        String tempMessage = URLEncoder.encode(encryptResultBase64);
//        String cburl = URLEncoder.encode(weifengwang_notify);
//        String tempAuthUrl = "https://www.enterpriseservice.cn/auth/#/authorization?webAuthorizeChannelCode=qkplf&cburl="+cburl+"&message="+tempMessage+"&url_id="+url_id;
//        log.info("授权链接: "+tempAuthUrl);
//        //保存记录
//        CnWeiFengWangAuth weiFengWangAuth = new CnWeiFengWangAuth();
//        weiFengWangAuth.setAppId(Integer.parseInt(reqUserDB.getAppId()));
//        weiFengWangAuth.setUid(reqUserDB.getId());
//        weiFengWangAuth.setOrderNo(tempOrderNo);
//        weiFengWangAuth.setCompanyName(companyName);
//        weiFengWangAuth.setRemainTimes(remainTimes);
//        weiFengWangAuth.setExpireTimeHour(expireTimeHour);
//        weiFengWangAuth.setExpireTime(expireTime);
//        weiFengWangAuth.setReportPermission("");
//        weiFengWangAuth.setCburl(cburl);
//        weiFengWangAuth.setUrlId(url_id);
//        weiFengWangAuth.setCreateTime(DateUtils.getNowTime());
//        weiFengWangAuth.setAuthUrl(tempAuthUrl);
//        int success = weiFengWangAuthMapper.insert(weiFengWangAuth);
//        if (success == 0) {
//            return JsonResult.error(ResultCode.not_exists,"服务繁忙，请稍后在试");
//        }
//        return JsonResult.success("成功").data(tempAuthUrl).put("orderNo", tempOrderNo);
//    }
//
//    @RequestMapping("/api/getEnterpriseServiceReportUrlPdf")
//    public Map<String, Object> getEnterpriseServiceReportUrlPdf(HttpServletRequest request) {
//        String appCode = request.getHeader("zrjkAppcode");
//        //检测app所属
//        CnApp cnApp = appDBMapper.selectAppByAppCode(appCode);
//        if (cnApp == null)
//            return JsonResult.error(ResultCode.app_not_exists,"app不存在");
//        //请求参数
//        String token = request.getParameter("token");
//        String orderNo = request.getParameter("orderNo");
//        String companyName = request.getParameter("companyName");
//        if (StringUtils.isEmpty(token)
//                || StringUtils.isEmpty(orderNo)) {
//            return JsonResult.error(ResultCode.not_exists,"缺少参数");
//        }
//        log.info("getEnterpriseServiceAuthorization token="+token+"\torderNo="+orderNo+"\tcompanyName="+companyName);
//        //用户校验
//        VerifyDB verifyDB = verifyDBMapper.getVerifyDBByToken(token);
//        if (verifyDB == null) {
//            return JsonResult.error(ResultCode.token_error,"请重新登录");
//        }
//        UserDB reqUserDB = userDBMapper.getUserById(verifyDB.getUid());
//        if (reqUserDB == null) {
//            return JsonResult.error(ResultCode.not_exists,"用户不存在");
//        }
//        //税务校验
//        CnWeiFengWangAuth db_w = weiFengWangAuthMapper.getByCompanyName(companyName);
//        if (db_w == null) {
//            return JsonResult.error(ResultCode.token_error,"不存在税务授权记录");
//        }
//        if (!companyName.equals(db_w.getCompanyName())) {
//            return JsonResult.error(ResultCode.token_error,"税务公司名称不一致");
//        }
//        int diffDay = DateUtils.getDiffDay(db_w.getCreateTime(), DateUtils.getNowTime());
//        if (diffDay > 180) {
//            return JsonResult.error(ResultCode.token_error,"超过授权有效时间");
//        }
//        if (!StringUtils.isEmpty(db_w.getIndexesReportUrlPdf())) {
//            log.info("存在pdf文件，直接返回");
//            Map<String, Object> rMap = new HashMap<>();
//            rMap.put("auth", db_w);
//            rMap.put("PDFURL", db_w.getIndexesReportUrlPdf());
//            return JsonResult.success("成功").data(rMap);
//        }
//        log.info("不存在pdf文件，获取pdf");
//        //已经授权，获取信息
//        //发票
//        String params2 = "interfaceCode="+weifengwang_interfaceCode
//                +"&secretKey="+ weifengwang_secretKey
//                +"&order_no="+ db_w.getOrderNo()
//                +"&tax_no="+db_w.getTaxNo()
//                +"&taxpayer_id="+db_w.getNSRSBH();
//        String getInvoiceInfoUrl = "https://api.wfq2020.com/mini-program-index-api/indexes/report_url/pdf?"+params2;
//        log.info("getEnterpriseServiceInfo 获取融资服务报告pdfurl："+getInvoiceInfoUrl);
//        Map tmepGetTaxCompanyInfoResultMap = restTemplate.getForObject(getInvoiceInfoUrl, Map.class);
//        String getTaxCompanyInfoResultResultStr = new Gson().toJson(tmepGetTaxCompanyInfoResultMap);
//        InvoiceInfo invoiceInfo = new Gson().fromJson(getTaxCompanyInfoResultResultStr, InvoiceInfo.class);
//        log.info("getEnterpriseServiceInfo 获取融资服务报告pdf结果："+getTaxCompanyInfoResultResultStr);
////
////        String getTaxInfoUrl = "https://api.wfq2020.com/mini-program-index-api/indexes/tax_info?"+params2;
////        log.info("getEnterpriseServiceInfo 税务url："+getTaxInfoUrl);
////        Map tmepGetTaxInfoResultMap = restTemplate.getForObject(getTaxInfoUrl, Map.class);
////        String getTaxInfoResultStr = new Gson().toJson(tmepGetTaxInfoResultMap);
////        log.info("getEnterpriseServiceInfo 税务结果："+getTaxInfoResultStr);
////
////        String getCompanyBasicInfoUrl = "https://api.wfq2020.com/mini-program-index-api/indexes/company_basic_info?"+params2;
////        log.info("getEnterpriseServiceInfo 公司基本信息url："+getCompanyBasicInfoUrl);
////        Map tmepGetCompanyBasicResultMap = restTemplate.getForObject(getCompanyBasicInfoUrl, Map.class);
////        String getCompanyBasicResultStr = new Gson().toJson(tmepGetCompanyBasicResultMap);
////        log.info("getEnterpriseServiceInfo 公司基本信息结果："+getCompanyBasicResultStr);
////
////        String getFinanceInfoUrl = "https://api.wfq2020.com/mini-program-index-api/indexes/finance_info?"+params2;
////        log.info("getEnterpriseServiceInfo 财报信息url："+getFinanceInfoUrl);
////        Map tmepGetFinanceInfoResultMap = restTemplate.getForObject(getFinanceInfoUrl, Map.class);
////        String getFinanceInfoResultStr = new Gson().toJson(tmepGetFinanceInfoResultMap);
////        log.info("getEnterpriseServiceInfo 财报信息结果："+getFinanceInfoResultStr);
//
//        if (!StringUtils.isEmpty(invoiceInfo.getData())
//                && !StringUtils.isEmpty(invoiceInfo.getData().getReportUrl())) {
//            db_w.setIndexesReportUrlPdf(invoiceInfo.getData().getReportUrl());
//            int success = weiFengWangAuthMapper.updateIndexesReportUrlPdf(db_w);
//        } else {
//            return JsonResult.error(ResultCode.token_error,""+invoiceInfo.getMessage());
//        }
//
//        Map<String, Object> rMap = new HashMap<>();
//        rMap.put("auth", db_w);
//        rMap.put("PDFURL", invoiceInfo.getData().getReportUrl());
////        rMap.put("invoiceInfo", tmepGetTaxCompanyInfoResultMap);
////        rMap.put("taxInfo", tmepGetTaxInfoResultMap);
////        rMap.put("companyBasic", tmepGetCompanyBasicResultMap);
////        rMap.put("financeInfo", tmepGetFinanceInfoResultMap);
//        return JsonResult.success("成功").data(rMap);
//    }
//
//    @RequestMapping("/api/getEnterpriseServiceReportUrlPdf/v2")
//    public Map<String, Object> getEnterpriseServiceReportUrlPdfV2(HttpServletRequest request) {
//        String appCode = request.getHeader("zrjkAppcode");
//        //检测app所属
//        CnApp cnApp = appDBMapper.selectAppByAppCode(appCode);
//        if (cnApp == null)
//            return JsonResult.error(ResultCode.app_not_exists,"app不存在");
//        //请求参数
//        String token = request.getParameter("token");
//        String creditAssessId = request.getParameter("creditAssessId");
//        String companyName = request.getParameter("companyName");
//        if (StringUtils.isEmpty(token)
//                || StringUtils.isEmpty(creditAssessId)
//                || StringUtils.isEmpty(companyName)) {
//            return JsonResult.error(ResultCode.not_exists,"缺少参数");
//        }
//        log.info("getEnterpriseServiceAuthorization token="+token+"\tcreditAssessId="+creditAssessId+"\tcompanyName="+companyName);
//        //用户校验
//        VerifyDB verifyDB = verifyDBMapper.getVerifyDBByToken(token);
//        if (verifyDB == null) {
//            return JsonResult.error(ResultCode.token_error,"请重新登录");
//        }
//        UserDB reqUserDB = userDBMapper.getUserById(verifyDB.getUid());
//        if (reqUserDB == null) {
//            return JsonResult.error(ResultCode.not_exists,"用户不存在");
//        }
//        //税务校验
//        CnWeiFengWangAuth db_w = weiFengWangAuthMapper.getByCompanyName(companyName);
//        if (db_w == null) {
//            return JsonResult.error(ResultCode.token_error,"不存在税务授权记录");
//        }
//        if (!companyName.equals(db_w.getCompanyName())) {
//            return JsonResult.error(ResultCode.token_error,"税务公司名称不一致");
//        }
//        int diffDay = DateUtils.getDiffDay(db_w.getCreateTime(), DateUtils.getNowTime());
//        if (diffDay > 180) {
//            return JsonResult.error(ResultCode.token_error,"超过授权有效时间");
//        }
//        if (!StringUtils.isEmpty(db_w.getIndexesReportUrlPdf())) {
//            log.info("存在pdf文件，直接返回");
//            Map<String, Object> rMap = new HashMap<>();
//            rMap.put("auth", db_w);
//            rMap.put("PDFURL", db_w.getIndexesReportUrlPdf());
//            return JsonResult.success("成功").data(rMap);
//        }
//        log.info("不存在pdf文件，获取pdf");
//        //已经授权，获取信息
//        //发票
//        String params2 = "interfaceCode="+weifengwang_interfaceCode
//                +"&secretKey="+ weifengwang_secretKey
//                +"&order_no="+ db_w.getOrderNo()
//                +"&tax_no="+db_w.getTaxNo()
//                +"&taxpayer_id="+db_w.getNSRSBH();
//        String getInvoiceInfoUrl = "https://api.wfq2020.com/mini-program-index-api/indexes/report_url/pdf?"+params2;
//        log.info("getEnterpriseServiceInfo 获取融资服务报告pdfurl："+getInvoiceInfoUrl);
//        Map tmepGetTaxCompanyInfoResultMap = restTemplate.getForObject(getInvoiceInfoUrl, Map.class);
//        String getTaxCompanyInfoResultResultStr = new Gson().toJson(tmepGetTaxCompanyInfoResultMap);
//        InvoiceInfo invoiceInfo = new Gson().fromJson(getTaxCompanyInfoResultResultStr, InvoiceInfo.class);
//        log.info("getEnterpriseServiceInfo 获取融资服务报告pdf结果："+getTaxCompanyInfoResultResultStr);
////
////        String getTaxInfoUrl = "https://api.wfq2020.com/mini-program-index-api/indexes/tax_info?"+params2;
////        log.info("getEnterpriseServiceInfo 税务url："+getTaxInfoUrl);
////        Map tmepGetTaxInfoResultMap = restTemplate.getForObject(getTaxInfoUrl, Map.class);
////        String getTaxInfoResultStr = new Gson().toJson(tmepGetTaxInfoResultMap);
////        log.info("getEnterpriseServiceInfo 税务结果："+getTaxInfoResultStr);
////
////        String getCompanyBasicInfoUrl = "https://api.wfq2020.com/mini-program-index-api/indexes/company_basic_info?"+params2;
////        log.info("getEnterpriseServiceInfo 公司基本信息url："+getCompanyBasicInfoUrl);
////        Map tmepGetCompanyBasicResultMap = restTemplate.getForObject(getCompanyBasicInfoUrl, Map.class);
////        String getCompanyBasicResultStr = new Gson().toJson(tmepGetCompanyBasicResultMap);
////        log.info("getEnterpriseServiceInfo 公司基本信息结果："+getCompanyBasicResultStr);
////
////        String getFinanceInfoUrl = "https://api.wfq2020.com/mini-program-index-api/indexes/finance_info?"+params2;
////        log.info("getEnterpriseServiceInfo 财报信息url："+getFinanceInfoUrl);
////        Map tmepGetFinanceInfoResultMap = restTemplate.getForObject(getFinanceInfoUrl, Map.class);
////        String getFinanceInfoResultStr = new Gson().toJson(tmepGetFinanceInfoResultMap);
////        log.info("getEnterpriseServiceInfo 财报信息结果："+getFinanceInfoResultStr);
//
//        if (!StringUtils.isEmpty(invoiceInfo.getData())
//                && !StringUtils.isEmpty(invoiceInfo.getData().getReportUrl())) {
//            db_w.setIndexesReportUrlPdf(invoiceInfo.getData().getReportUrl());
//            int success = weiFengWangAuthMapper.updateIndexesReportUrlPdf(db_w);
//        } else {
//            return JsonResult.error(ResultCode.token_error,""+invoiceInfo.getMessage());
//        }
//
//        Map<String, Object> rMap = new HashMap<>();
//        rMap.put("auth", db_w);
//        rMap.put("PDFURL", invoiceInfo.getData().getReportUrl());
////        rMap.put("invoiceInfo", tmepGetTaxCompanyInfoResultMap);
////        rMap.put("taxInfo", tmepGetTaxInfoResultMap);
////        rMap.put("companyBasic", tmepGetCompanyBasicResultMap);
////        rMap.put("financeInfo", tmepGetFinanceInfoResultMap);
//        return JsonResult.success("成功").data(rMap);
//    }
//
//    @RequestMapping("/api/getEnterpriseServiceAuthorization")
//    public Map<String, Object> getEnterpriseServiceAuthorization(HttpServletRequest request) {
//        String appCode = request.getHeader("zrjkAppcode");
//        //检测app所属
//        CnApp cnApp = appDBMapper.selectAppByAppCode(appCode);
//        if (cnApp == null)
//            return JsonResult.error(ResultCode.app_not_exists,"app不存在");
//        //请求参数
//        String token = request.getParameter("token");
//        String orderNo = request.getParameter("orderNo");
//        String companyName = request.getParameter("companyName");
//        if (StringUtils.isEmpty(token)
//                || StringUtils.isEmpty(companyName)) {
//            return JsonResult.error(ResultCode.not_exists,"缺少参数");
//        }
//        log.info("getEnterpriseServiceAuthorization token="+token+"\torderNo="+orderNo+"\tcompanyName="+companyName);
//        //用户校验
//        VerifyDB verifyDB = verifyDBMapper.getVerifyDBByToken(token);
//        if (verifyDB == null) {
//            return JsonResult.error(ResultCode.token_error,"请重新登录");
//        }
//        UserDB reqUserDB = userDBMapper.getUserById(verifyDB.getUid());
//        if (reqUserDB == null) {
//            return JsonResult.error(ResultCode.not_exists,"用户不存在");
//        }
//        //税务校验
//        CnWeiFengWangAuth db_w = weiFengWangAuthMapper.getByCompanyName(companyName);
//        if (db_w == null) {
//            return JsonResult.error(ResultCode.token_error,"不存在税务授权记录");
//        }
//        if (!companyName.equals(db_w.getCompanyName())) {
//            return JsonResult.error(ResultCode.token_error,"税务公司名称不一致");
//        }
//        int diffDay = DateUtils.getDiffDay(db_w.getCreateTime(), DateUtils.getNowTime());
//        if (diffDay > 180) {
//            return JsonResult.error(ResultCode.token_error,"超过授权有效时间");
//        }
//        //已经授权，获取信息
////        //发票
////        String params2 = "interfaceCode="+weifengwang_interfaceCode
////                +"&secretKey="+ weifengwang_secretKey
////                +"&order_no="+ db_w.getOrderNo()
////                +"&tax_no="+db_w.getTaxNo()
////                +"&taxpayer_id="+db_w.getNSRSBH();
////        String getInvoiceInfoUrl = "https://api.wfq2020.com/mini-program-index-api/indexes/invoice_info?"+params2;
////        log.info("getEnterpriseServiceInfo 发票url："+getInvoiceInfoUrl);
////        Map tmepGetTaxCompanyInfoResultMap = restTemplate.getForObject(getInvoiceInfoUrl, Map.class);
////        String getTaxCompanyInfoResultResultStr = new Gson().toJson(tmepGetTaxCompanyInfoResultMap);
////        InvoiceInfo invoiceInfo = new Gson().fromJson(getTaxCompanyInfoResultResultStr, InvoiceInfo.class);
////        log.info("getEnterpriseServiceInfo 发票结果："+getTaxCompanyInfoResultResultStr);
////
////        String getTaxInfoUrl = "https://api.wfq2020.com/mini-program-index-api/indexes/tax_info?"+params2;
////        log.info("getEnterpriseServiceInfo 税务url："+getTaxInfoUrl);
////        Map tmepGetTaxInfoResultMap = restTemplate.getForObject(getTaxInfoUrl, Map.class);
////        String getTaxInfoResultStr = new Gson().toJson(tmepGetTaxInfoResultMap);
////        log.info("getEnterpriseServiceInfo 税务结果："+getTaxInfoResultStr);
////
////        String getCompanyBasicInfoUrl = "https://api.wfq2020.com/mini-program-index-api/indexes/company_basic_info?"+params2;
////        log.info("getEnterpriseServiceInfo 公司基本信息url："+getCompanyBasicInfoUrl);
////        Map tmepGetCompanyBasicResultMap = restTemplate.getForObject(getCompanyBasicInfoUrl, Map.class);
////        String getCompanyBasicResultStr = new Gson().toJson(tmepGetCompanyBasicResultMap);
////        log.info("getEnterpriseServiceInfo 公司基本信息结果："+getCompanyBasicResultStr);
////
////        String getFinanceInfoUrl = "https://api.wfq2020.com/mini-program-index-api/indexes/finance_info?"+params2;
////        log.info("getEnterpriseServiceInfo 财报信息url："+getFinanceInfoUrl);
////        Map tmepGetFinanceInfoResultMap = restTemplate.getForObject(getFinanceInfoUrl, Map.class);
////        String getFinanceInfoResultStr = new Gson().toJson(tmepGetFinanceInfoResultMap);
////        log.info("getEnterpriseServiceInfo 财报信息结果："+getFinanceInfoResultStr);
//
//        Map<String, Object> rMap = new HashMap<>();
//        rMap.put("auth", db_w);
////        rMap.put("invoiceInfo", tmepGetTaxCompanyInfoResultMap);
////        rMap.put("taxInfo", tmepGetTaxInfoResultMap);
////        rMap.put("companyBasic", tmepGetCompanyBasicResultMap);
////        rMap.put("financeInfo", tmepGetFinanceInfoResultMap);
//        return JsonResult.success("成功").data(rMap);
//    }
//
//    @RequestMapping("/api/getEnterpriseServiceInfo")
//    public Map<String, Object> getEnterpriseServiceInfo(HttpServletRequest request) {
////        String appCode = request.getHeader("zrjkAppcode");
////        //检测app所属
////        CnApp cnApp = appDBMapper.selectAppByAppCode(appCode);
////        if (cnApp == null)
////            return JsonResult.error(ResultCode.app_not_exists,"app不存在");
//        //请求参数
//        String token = request.getParameter("token");
//        String orderNo = request.getParameter("orderNo");
//        String companyName = request.getParameter("companyName");
//        if (StringUtils.isEmpty(token)
//                || StringUtils.isEmpty(orderNo)
//                || StringUtils.isEmpty(companyName)) {
//            return JsonResult.error(ResultCode.not_exists,"缺少参数");
//        }
//        log.info("getEnterpriseServiceInfo token="+token+"\torderNo="+orderNo+"\tcompanyName="+companyName);
//        //用户校验
//        VerifyDB verifyDB = verifyDBMapper.getVerifyDBByToken(token);
//        if (verifyDB == null) {
//            return JsonResult.error(ResultCode.token_error,"请重新登录");
//        }
//        UserDB reqUserDB = userDBMapper.getUserById(verifyDB.getUid());
//        if (reqUserDB == null) {
//            return JsonResult.error(ResultCode.not_exists,"用户不存在");
//        }
//        //税务校验
//        CnWeiFengWangAuth db_w = weiFengWangAuthMapper.getByOrderNoAndCompanyName(orderNo, companyName);
//        if (db_w == null) {
//            return JsonResult.error(ResultCode.token_error,"不存在税务授权记录");
//        }
//        if (!companyName.equals(db_w.getCompanyName())) {
//            return JsonResult.error(ResultCode.token_error,"税务公司名称不一致");
//        }
//        log.info("getEnterpriseServiceInfo db_w："+new Gson().toJson(db_w));
//        //用于提前判断当前微风企站点状态
//        String params = "interfaceCode="+weifengwang_interfaceCode+"&secretKey="+weifengwang_secretKey;
//        String siteUrl = "https://api.wfq2020.com/wuneng-web-api/v2/api/serve/siteMessage?"+params;
//        log.info("getEnterpriseServiceInfo siteUrl："+siteUrl);
//        Map tmepSiteMap = restTemplate.getForObject(siteUrl, Map.class);
//        String siteResultStr = new Gson().toJson(tmepSiteMap);
//        log.info("getEnterpriseServiceInfo siteResultStr："+siteResultStr);
////        UserId userIdResultMap = new Gson().fromJson(userIdResultStr, UserId.class);
////        log.info("getEnterpriseServiceInfo userIdResultMap："+new Gson().toJson(userIdResultMap));
//        //发票
//        String params2 = "interfaceCode="+weifengwang_interfaceCode
//                +"&secretKey="+ weifengwang_secretKey
//                +"&order_no="+ db_w.getOrderNo()
//                +"&tax_no="+db_w.getTaxNo()
//                +"&taxpayer_id="+db_w.getNSRSBH();
//        String getInvoiceInfoUrl = "https://api.wfq2020.com/mini-program-index-api/indexes/invoice_info?"+params2;
//        log.info("getEnterpriseServiceInfo 发票url："+getInvoiceInfoUrl);
//        Map tmepGetTaxCompanyInfoResultMap = restTemplate.getForObject(getInvoiceInfoUrl, Map.class);
//        String getTaxCompanyInfoResultResultStr = new Gson().toJson(tmepGetTaxCompanyInfoResultMap);
//        log.info("getEnterpriseServiceInfo 发票结果："+getTaxCompanyInfoResultResultStr);
//
//        String getTaxInfoUrl = "https://api.wfq2020.com/mini-program-index-api/indexes/tax_info?"+params2;
//        log.info("getEnterpriseServiceInfo 税务url："+getTaxInfoUrl);
//        Map tmepGetTaxInfoResultMap = restTemplate.getForObject(getTaxInfoUrl, Map.class);
//        String getTaxInfoResultStr = new Gson().toJson(tmepGetTaxInfoResultMap);
//        log.info("getEnterpriseServiceInfo 税务结果："+getTaxInfoResultStr);
//
//        String getCompanyBasicInfoUrl = "https://api.wfq2020.com/mini-program-index-api/indexes/company_basic_info?"+params2;
//        log.info("getEnterpriseServiceInfo 公司基本信息url："+getCompanyBasicInfoUrl);
//        Map tmepGetCompanyBasicResultMap = restTemplate.getForObject(getCompanyBasicInfoUrl, Map.class);
//        String getCompanyBasicResultStr = new Gson().toJson(tmepGetCompanyBasicResultMap);
//        log.info("getEnterpriseServiceInfo 公司基本信息结果："+getCompanyBasicResultStr);
//
//        String getFinanceInfoUrl = "https://api.wfq2020.com/mini-program-index-api/indexes/finance_info?"+params2;
//        log.info("getEnterpriseServiceInfo 财报信息url："+getFinanceInfoUrl);
//        Map tmepGetFinanceInfoResultMap = restTemplate.getForObject(getFinanceInfoUrl, Map.class);
//        String getFinanceInfoResultStr = new Gson().toJson(tmepGetFinanceInfoResultMap);
//        log.info("getEnterpriseServiceInfo 财报信息结果："+getFinanceInfoResultStr);
//
//        Map<String, Object> rMap = new HashMap<>();
//        rMap.put("auth", db_w);
//        rMap.put("taxInfo", tmepGetTaxInfoResultMap);
//        rMap.put("companyBasic", tmepGetCompanyBasicResultMap);
//        rMap.put("financeInfo", tmepGetFinanceInfoResultMap);
//        return JsonResult.success("成功").data(rMap);
//    }
//
//}
